﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="AccountManagement.aspx.cs" Inherits="SwenAssigment.AccountManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>User Account Management</h1>

        <table style="width: 100%;">
            <tr>
                <td class="auto-style10">Search by</td>
                <td class="auto-style11"></td>
                <td class="auto-style4"></td>
            </tr>
            <tr>
                <td class="auto-style5">User Id:</td>
                <td class="auto-style9">
                    <asp:TextBox ID="TextBox2" runat="server" ValidationGroup="a"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox2" ErrorMessage="*Require" ForeColor="Red" ValidationGroup="a"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox2" ErrorMessage="*Only allow Number" ForeColor="Red" ValidationExpression="[0-9]{1,}$" ValidationGroup="a"></asp:RegularExpressionValidator>
                </td>
                <td>
                    <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Search" ValidationGroup="a" />
                </td>
            </tr>
            <tr>
                <td class="auto-style5">Staff Name:</td>
                <td class="auto-style9">
                    <asp:TextBox ID="TextBox3" runat="server" ValidationGroup="b"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBox3" ErrorMessage="*Require" ForeColor="Red" ValidationGroup="b"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TextBox3" ErrorMessage="*Allow only letter min 4 max 20" ForeColor="Red" ValidationExpression="[a-zA-Z]{4,20}$" ValidationGroup="b"></asp:RegularExpressionValidator>
                </td>
                <td>
                    <asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="Search" ValidationGroup="b" />
                </td>
            </tr>
            <tr>
                <td class="auto-style5">User Name:</td>
                <td class="auto-style9">
                    <asp:TextBox ID="TextBox4" runat="server" ValidationGroup="c"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="TextBox3" ErrorMessage="*Require" ForeColor="Red" ValidationGroup="c"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="TextBox3" ErrorMessage="*Allow only letter min 4 max 20" ForeColor="Red" ValidationExpression="[a-zA-Z]{4,20}$" ValidationGroup="c"></asp:RegularExpressionValidator>
                </td>
                <td>
                    <asp:Button ID="Button7" runat="server" OnClick="Button7_Click" Text="Search" ValidationGroup="c" />
                </td>
            </tr>
            <tr>
                <td class="auto-style5">Role:</td>
                <td class="auto-style9">
                    <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" ValidationGroup="d">
                        <asp:ListItem>Normal</asp:ListItem>
                        <asp:ListItem>Management</asp:ListItem>
                        <asp:ListItem>Admin</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:Button ID="Button5" runat="server" OnClick="Button5_Click" Text="Search" ValidationGroup="d" />
                </td>
            </tr>
            <tr>
                <td class="auto-style5">&nbsp;</td>
                <td class="auto-style9">&nbsp;</td>
                <td>
                    <asp:Button ID="Button6" runat="server" OnClick="Button6_Click" Text="Display all" />
                </td>
            </tr>
        </table>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True" DataKeyNames="User_ID,LockRate,Username" PageSize="5" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnPageIndexChanged="GridView1_PageIndexChanged" OnRowDeleting="GridView1_RowDeleting">
        <Columns>
            <asp:BoundField DataField="User_ID" HeaderText="User Id" />
            <asp:BoundField DataField="Staff_ID" HeaderText="Staff ID" />
            <asp:BoundField DataField="Username" HeaderText="User Name" />
            <asp:BoundField DataField="Role" HeaderText="Role" />
            <asp:BoundField DataField="LockRate" HeaderText="Lock Rate" />
            <asp:BoundField DataField="Staff_Name" HeaderText="Staff Name" />
            <asp:BoundField DataField="Contact_Number" HeaderText="Contact Number" />
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Select" Text="reSet Lock" Visible='<%# Convert.ToBoolean(Eval("LockStatus")) == true ? true : false %>'></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Select" Text="Lock" Visible='<%# Convert.ToBoolean(Eval("LockStatus")) == false ? true : false %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:HyperLinkField DataNavigateUrlFields="User_ID" DataNavigateUrlFormatString="AccountManageDetail.aspx?uid={0}" Text="Edit" />
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Delete" OnClientClick="return confirm('confirm to delete?');" Text="Delete"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            Data not Found
        </EmptyDataTemplate>
    </asp:GridView>
</asp:Content>
